#
# Franklin and Hopper
# need to 
#>module unload PrgEnv-pgi
#>module load PrgEnv-gnu
CC = CC
MPCC = CC -lmpich_threadm
OPENMP = -fopenmp	
CFLAGS = -O3  #-pg -g -DDEBUG
#CFLAGS = -g -lm
LIBS = -lm -O3 #-pg
ifeq ($(PE_ENV),PGI)
 OPENMP = -mp	
 CFLAGS+= #-fastsse
endif

ifneq ($(TAUROOTDIR),)
	include  $(TAUROOTDIR)/include/Makefile
	CFLAGS+=$(TAU_INCLUDE) $(TAU_DEFS) -DTAU
#	LIBS+=$(TAU_MPI_LIBS) $(TAU_LIBS) 
	LIBS+= $(TAU_LIBS) 
endif


TARGETS = es-bvs-bl-hybrid es-bvs-bl-mpi es-bvs-bl-serial es-bvs-bl-openmp 

all:	$(TARGETS)



es-bvs-bl-serial: es-bvs-bl-serial.o es-bvs-bl-common.o
	$(CC) -o $@ $(LIBS) es-bvs-bl-serial.o es-bvs-bl-common.o
es-bvs-bl-serial.o: es-bvs-bl-serial.cpp es-bvs-bl-common.h
	$(CC) -c $(CFLAGS) es-bvs-bl-serial.cpp
es-bvs-bl-openmp: es-bvs-bl-openmp.o es-bvs-bl-common.o
	$(CC) -o $@ $(OPENMP) $(LIBS) es-bvs-bl-openmp.o es-bvs-bl-common.o
es-bvs-bl-openmp.o: es-bvs-bl-openmp.cpp es-bvs-bl-common.h
	$(CC) -c $(OPENMP) $(CFLAGS) es-bvs-bl-openmp.cpp
es-bvs-bl-common.o: es-bvs-bl-common.cpp es-bvs-bl-common.h
	$(CC) -c $(CFLAGS) es-bvs-bl-common.cpp
es-bvs-bl-mpi.o: es-bvs-bl-mpi.cpp es-bvs-bl-common.h
	$(MPCC) -c $(CFLAGS) es-bvs-bl-mpi.cpp
es-bvs-bl-hybrid.o: es-bvs-bl-hybrid.cpp es-bvs-bl-common.h
	$(MPCC) -c $(OPENMP) $(CFLAGS) es-bvs-bl-hybrid.cpp


es-bvs-bl-mpi: es-bvs-bl-mpi.o es-bvs-bl-common.o
	$(MPCC) -o $@  es-bvs-bl-mpi.o es-bvs-bl-common.o $(LIBS)
es-bvs-bl-hybrid: es-bvs-bl-hybrid.o es-bvs-bl-common.o
	$(MPCC) -o $@  es-bvs-bl-hybrid.o es-bvs-bl-common.o $(LIBS) $(OPENMP) -lmpich_threadm


clean:
	rm -f *.o $(TARGETS)
